#ifndef SortedOList_First
#define SortedOList_First
#ifdef __GNUG__
#pragma interface
#endif

#include "ObjList.h"

enum SObListFlags {
	SObListAscending    = BIT(eObjLast+2),
	SObListLast         = eObjLast+3
};

const bool
	cSortAscending= TRUE,
	cSortDescending= !cSortAscending;
		
//---- SortedObjList -----------------------------------------------------------

class SortedObjList : public ObjList {
public:
	MetaDef(SortedObjList);
	SortedObjList(bool order= cSortAscending);

	bool Ascending();

	//---- manipulation
	Object *Add(Object *a);

	//---- the following methods are overridden to preserve sorting order
	Object *AddFirst(Object*);
	Object *AddLast(Object*);
	Object *AddBefore(Object *op, Object *after);
	Object *AddBeforePtr(Object *op, Object *after);
	Object *AddAfter(Object *op, Object *before);
	Object *AddAfterPtr(Object *op, Object *before);
	Object *PutAt(Object *op, int idx);
protected:
	virtual int CompareObjects(Object*, Object*);
};

inline bool SortedObjList::Ascending()
	{ return TestFlag(SObListAscending); }

#endif
